package com.indeep.user.mapper.po;

import lombok.AllArgsConstructor;

import java.util.Objects;

@AllArgsConstructor
public enum Sexes {
    UNSELECTED(0, ""),
    MALE(1, "男"),
    FEMALE(2, "女");

    public final Integer index;
    public final String str;


    //通过ID获取枚举值
    public static Sexes getByIndex(Integer index) {
        if (index == null) {
            return null;
        }
        for (Sexes s : values()) {
            if (Objects.equals(s.index, index)) {
                return s;
            }
        }
        return null;
    }

    //通过str获取枚举值
    public static Sexes getByStr(String str) {
        if (str == null) {
            return null;
        }
        for (Sexes s : values()) {
            if (Objects.equals(s.str, str)) {
                return s;
            }
        }
        return null;
    }

}
